<?php
/*
$host = '127.0.0.1';       // 本地数据库一般用 127.0.0.1 或 localhost
$port = 3306;
$db   = 'test';
$user = '1031';            // 修改为你的用户名
$pass = '103101';          // 修改为你的密码
$charset = 'utf8mb4';
*/
$host = '169.254.240.86';//169.254.240.86
$port = 3306;
$db   = 'test';
$user = 'River';
$pass = '103101';
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;port=$port;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
];

try {
    $pdo = new PDO($dsn, $user, $pass, $options);
    $pdo->exec("set names utf8mb4");
} catch (\PDOException $e) {
    throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
?>